/*     */ package com.newcrm.businessarchives;
/*     */ 
/*     */ import com.newcrm.util.Util;
/*     */ import java.io.IOException;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.jsoup.Connection;
/*     */ import org.jsoup.Connection.Method;
/*     */ import org.jsoup.Connection.Response;
/*     */ import org.jsoup.Jsoup;
/*     */ import org.jsoup.nodes.Document;
/*     */ import org.jsoup.nodes.Element;
/*     */ import org.jsoup.select.Elements;
/*     */ 
/*     */ public class WuhanSearchEngine extends SearchEngine
/*     */ {
/*  21 */   private static Logger logger = Logger.getLogger(WuhanSearchEngine.class
/*  22 */     .getName());
/*     */ 
/*  24 */   private Map<String, String> params = new HashMap();
/*     */ 
/*     */   public WuhanSearchEngine(String name) {
/*  27 */     this.name = standardizedName(name);
/*  28 */     this.params.put("企业名称：", "CompanyName");
/*  29 */     this.params.put("企业类型：", "CompanyType");
/*  30 */     this.params.put("注册号：", "SN");
/*  31 */     this.params.put("注册资本：", "RegisteredCapital");
/*  32 */     this.params.put("法定代表人/负责人：", "Header");
/*  33 */     this.params.put("住所：", "Address");
/*  34 */     this.params.put("成立日期：", "FoundedDate");
/*  35 */     this.params.put("经营截至期限：", "OperatingPeriodEnd");
/*  36 */     this.params.put("登记机关：", "RegistrationAuthority");
/*  37 */     this.params.put("一般经营范围：", "BusinessScope");
/*     */   }
/*     */ 
/*     */   protected Map<String, Object> getCompanyByWeb()
/*     */   {
/*     */     try
/*     */     {
/*  44 */       Connection.Response res = 
/*  45 */         Jsoup.connect("http://gssoso.whhd.gov.cn:8086/soso/search")
/*  46 */         .data(new String[] { 
/*  46 */         "channelid", 
/*  47 */         "20228", 
/*  48 */         "chooseId", 
/*  49 */         "10", 
/*  50 */         "searchword", 
/*  51 */         "企业名称/10,经营状态/1,注册号/1,负责人/1,一般经营范围/1,许可经营范围/1,登记机关/1,管辖工商所/1,住所/1+=" + 
/*  52 */         this.name, "searchword1", this.name, 
/*  53 */         "sortfield", "+经营状态ID,RELEVANCE,-注册资本", "templet", 
/*  54 */         "zhyw_search_qyinfo.jsp" }).method(Connection.Method.POST)
/*  55 */         .userAgent("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6.6; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; .NET CLR 1.1.4322; .NET4.0C)").timeout(10000).execute();
/*     */ 
/*  57 */       Document doc = res.parse();
/*     */ 
/*  60 */       Elements links = doc.select("tr td a[class=right_list]");
/*  61 */       List detailsUrl = new ArrayList();
/*  62 */       for (Element item : links) {
/*  63 */         detailsUrl.add(item.absUrl("href"));
/*     */       }
/*     */ 
/*  66 */       if (detailsUrl.size() == 0) {
/*  67 */         return null;
/*     */       }
/*     */ 
/*  71 */       String url = (String)detailsUrl.get(0);
/*     */ 
/*  73 */       doc = Jsoup.connect(url).userAgent("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6.6; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; .NET CLR 1.1.4322; .NET4.0C)").timeout(10000).get();
/*  74 */       links = doc.select("table tr td div[align=right]");
/*  75 */       if (links == null) {
/*  76 */         return null;
/*     */       }
/*     */ 
/*  79 */       Object info = new HashMap();
/*  80 */       for (Element item : links) {
/*  81 */         String key = item.text().trim();
/*  82 */         if (this.params.containsKey(key))
/*     */         {
/*  85 */           ((Map)info).put((String)this.params.get(key), item.parent()
/*  86 */             .nextElementSibling().text());
/*     */         }
/*     */       }
/*  88 */       ((Map)info).put(
/*  89 */         "OperatingPeriod", 
/*  90 */         ((Map)info).get("FoundedDate") + " - " + 
/*  91 */         ((Map)info).get("OperatingPeriodEnd"));
/*  92 */       ((Map)info).put("UpdateDate", Util.date2Str(new Date()));
/*  93 */       if (((Map)info).size() > 2) {
/*  94 */         super.saveDB((Map)info);
/*     */       }
/*  96 */       return (Map)info;
/*     */     } catch (IOException e) {
/*  98 */       logger.warn("get wuhan company info failed", e);
/*     */     }
/* 100 */     return null;
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.businessarchives.WuhanSearchEngine
 * JD-Core Version:    0.6.1
 */